import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../share/size_fill.dart';
import 'show_bottom_alert_dialog.dart';

class ShowCenterAlertDialog {
  static Future showAlert(
    BuildContext context, {
    required WidgetBuilder builder,
    double radius = 5,
    double? width,
    double? height,
    Color bgColor = Colors.white,
  }) async {
    assert(builder != null);
    if (width == null) {
      width = SizeFill.setRx(300);
    }
    if (height == null) {
      height = SizeFill.setRx(240);
    }

    final future = await showDialog(
        context: context,
        useSafeArea: false,
        builder: (context) {
          return WillPopScope(
            onWillPop: () async {
              return false;
            },
            child: Scaffold(
              backgroundColor: Colors.transparent,
              body: Center(
                child: Container(
                  width: width,
                  height: height,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(SizeFill.setRx(6)),
                    color: bgColor,
                  ),
                  child: builder(context),
                ),
              ),
            ),
          );
        });
    return future;
  }
}
